#!/bin/bash
#
# description:
#   wine explorer application builder
#
# editor:
#   mattintosh4
#
# more info:
#   http://mattintosh.blog.so-net.ne.jp/58238321

cat <<__EOS__

----------------------------------------------------------------
wine explorer application builder
----------------------------------------------------------------
editor:
    mattintosh4

more info:
    http://mattintosh.blog.so-net.ne.jp/58238321
----------------------------------------------------------------

__EOS__

APP=WineExplorer.app
CONTENTS=$APP/Contents
RESOURCES=$CONTENTS/Resources
MACOS=$CONTENTS/MacOS

mkdir -p $RESOURCES $MACOS

### Icons.icns ###
curl -o $RESOURCES/Icons.icns 'http://mattintosh4-devel.googlecode.com/git/icons/windows_alt.icns'

### Info.plist ###
cat > $CONTENTS/Info.plist <<__EOF__
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>script</string>
	<key>CFBundleIconFile</key>
	<string>Icons.icns</string>
	<key>CFBundleIdentifier</key>
	<string>com.wineexplorer.wineexplorer</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>WineExplorer</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleSignature</key>
	<string>APPL</string>
	<key>CFBundleVersion</key>
	<string>1.0.0</string>
</dict>
</plist>
__EOF__

### script ###
cat > $MACOS/script <<__EOF__
#!/bin/bash --login

wine explorer &
__EOF__
chmod +x $MACOS/script

### file check ###
echo -e "\n=> File check."
for f in $CONTENTS/Info.plist $RESOURCES/Icons.icns $MACOS/script
do
    echo -n "$f"...
    test -f $f && echo "OK" || echo "MISS"
done

echo -e "\n=> Complete."
